//package ms.db.mysql;
//
//import com.alibaba.druid.pool.DruidDataSource;
//import com.mchange.v2.c3p0.ComboPooledDataSource;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.orm.hibernate5.LocalSessionFactoryBean;
//import org.springframework.transaction.annotation.EnableTransactionManagement;
//
//import javax.sql.DataSource;
//import java.beans.PropertyVetoException;
//
//@Configuration
//@EnableTransactionManagement
//public class SessionFactory extends LocalSessionFactoryBean {
//    @Autowired
//    MySqlProperties mySqlProperties;
//
//    @Bean
//    @ConfigurationProperties(prefix = "spring.datasource")
//    MySqlProperties getMysqlProperties() {
//        return new MySqlProperties();
//    }
//
//    @Bean()
//    public DataSource dataSourceFactory() throws Exception {
//        DruidDataSource datasource = new DruidDataSource();
//        datasource.setUrl(mySqlProperties.getUrl());
//        datasource.setUsername(mySqlProperties.getUsername());
//        datasource.setPassword(mySqlProperties.getPassword());
//        datasource.setDriverClassName(mySqlProperties.getDriverClass());
//
//        //configuration
//        datasource.setInitialSize(mySqlProperties.getMinSize());
//        datasource.setMinIdle(mySqlProperties.getMinSize());
//        datasource.setMaxActive(mySqlProperties.getMaxSize());
//        datasource.setMaxWait(mySqlProperties.getTimeout());
////        datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
////        datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
//        datasource.setValidationQuery("select 1");
//        datasource.setTestWhileIdle(true);
//        datasource.setTestOnBorrow(false);
//        datasource.setTestOnReturn(false);
//        datasource.setPoolPreparedStatements(true);
//        datasource.setMaxPoolPreparedStatementPerConnectionSize(mySqlProperties.getMaxStatements());
//        return datasource;
//    }
//
//
//
//
//}
